<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/Reports' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card" style="margin-top: 20px">
      <el-input
        placeholder="请输入内容"
        class="input-with-select"
        style="width: 400px"
     
      >
        <el-button
          slot="append"
          icon="el-icon-search"
         
        ></el-button>
      </el-input>
      <el-table :data="tableData" border style="width: 100%; margin-top: 20px">
        <el-table-column type="index" label="#"> </el-table-column>
        <el-table-column prop="order_number" label="订单编号">
        </el-table-column>
        <el-table-column prop="order_price" label="订单价格"> </el-table-column>
        <el-table-column prop="pay_status" label="是否付款">
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.pay_status == 0"
              >未付款</el-tag
            >
            <el-tag type="danger" v-if="scope.row.pay_status == 1"
              >支付宝</el-tag
            >
            <el-tag type="danger" v-if="scope.row.pay_status == 2">微信</el-tag>
            <el-tag type="danger" v-if="scope.row.pay_status == 3"
              >银行卡</el-tag
            >
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"> </el-table-column>
        <el-table-column prop="create_time" label="下单时间">
          <template slot-scope="scope">
            {{ scope.row.create_time | time }}
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="mini"
              @click="edit(scope.row)"
            ></el-button>
            <el-button
              type="success"
              icon="el-icon-location"
              size="mini"
              @click="plan"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="info.pagenum"
        :page-sizes="[1, 3, 5, 7]"
        :page-size="info.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        style="margin-top: 10px"
      >
      </el-pagination>
      <!-- 编辑的模态框 -->
      <el-dialog title="修改地址" :visible.sync="dialogVisible" width="50%">
        <el-form
          :model="editForm"
          label-width="80px"
          :rules="rules"
          ref="editForm"
        >
          <el-form-item label="省市县" prop="addres">
            <el-cascader
              v-model="editForm.addres"
              :options="options"
              :props="{
                expandTrigger: 'hover',
                label: 'label',
                value: 'value',
                children: 'children',
              }"
              @change="handleChange"
            ></el-cascader>
          </el-form-item>
          <el-form-item label="详细地址" prop="addres1">
            <el-input v-model="editForm.addres1"></el-input>
          </el-form-item>
        </el-form>

        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogVisible = false"
            >确 定</el-button
          >
        </span>
      </el-dialog>
      <!-- 物流进度的模态框 -->
      <el-dialog
        title="查看物流进度"
        :visible.sync="dialogVisible1"
        width="50%"
      >
        <!-- 时间线 -->
        <el-timeline>
          <el-timeline-item
            v-for="(item, index) in activity.data"
            :key="index"
            :timestamp="item.time"
          >
            {{ item.context }}
          </el-timeline-item>
        </el-timeline>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible1 = false">取 消</el-button>
          <el-button type="primary" @click="dialogVisible1 = false"
            >确 定</el-button
          >
        </span>
      </el-dialog>
    </el-card>
  </div>
</template>

<script>
import options from "../assets/citydata.js";
import activity from "../assets/mydata.js";
export default {
  name: "MyVueOrders",

  data() {
    return {
      // 订单列表数据
      tableData: [],
      //   订单列表的参数
      info: {
    
        pagenum: 1,
        pagesize: 5,
      },
      //   总条数
      total: 0,
      // 显示隐藏编辑框
      dialogVisible: false,
      options,
      editForm: {},
      //   正则校验
      rules: {
        addres: [{ required: true, message: "请输入省市县", trigger: "blur" }],
        addres1: [
          { required: true, message: "请输入详细地址", trigger: "blur" },
        ],
      },

      //   物流进度的显示隐藏
      dialogVisible1: false,
      //   物流进度数据
      activity,
    };
  },

  mounted() {
 this.list()
  },

  methods: {
    // 渲染订单列表
    list() {
      this.$http.get(`orders`, { params: this.info }).then((res) => {
        console.log(res);
        if (res.data.meta.status === 200) {
          this.tableData = res.data.data.goods;
          this.total = res.data.data.total;
        } else {
          this.$message.error(res.data.meta.msg);
        }
      });
    },
    // 分页
    handleSizeChange(val) {
      this.info.pagesize = val;
      this.list();
    },
    handleCurrentChange(val) {
      this.info.pagenum = val;
      this.list();
    },
   
    // 修改
    edit() {
      this.dialogVisible = true;
    },
    // 物流进度
    plan() {
      this.dialogVisible1 = true;
    },

  },
};
</script>

<style lang="scss" scoped>
</style>